<template>
  <view>
    <view class="video_tab">
      <view class="video_tab_title">
        <view class="title_inner"
          ><uni-segmented-control
            :current="current"
            :values="items.map(v => v.title)"
            @clickItem="onClickItem"
            style-type="text"
            active-color="#d4237a"
          ></uni-segmented-control
        ></view>
        <view class="iconfont iconsearch"></view>
      </view>

      <view class="content">
        <view v-if="current < 4">
          <video-main
            :urlobj="{ url: items[current].url, params: items[current].params }"
          ></video-main>
        </view>
        <view v-if="current === 4">
          <video-category></video-category>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { uniSegmentedControl } from "@dcloudio/uni-ui";
import videoMain from "./video-main";
import videoCategory from "./video-category";
export default {
  data() {
    return {
      items: [
        {
          title: "推荐",
          url: "videoimg/v1/videowp/featured",
          params: { order: "hot", limit: 30, skip: 0 }
        },
        {
          title: "娱乐",
          url: "videoimg/v1/videowp/category/59b25abbe7bce76bc834198a",
          params: { order: "new", limit: 30, skip: 0 }
        },
        {
          title: "最新",
          url: "videoimg/v1/videowp/videowp",
          params: { order: "new", limit: 30, skip: 0 }
        },
        {
          title: "热门",
          url: "videoimg/v1/videowp/videowp",
          params: { order: "hot", limit: 30, skip: 0 }
        },
        {
          title: "分类",
         
        }
      ],
      current: 0
    };
  },
  methods: {
    onClickItem(index) {
      if (this.current !== index.currentIndex) {
        this.current = index.currentIndex;
      }
    }
  },
  components: {
    uniSegmentedControl,
    videoMain,
    videoCategory
  },
  onLoad() {}
};
</script>
<style lang="scss">
.video_tab {
  .video_tab_title {
    position: relative;
    .title_inner {
      width: 60%;
      margin: 0 auto;
    }
  }
}

.iconsearch {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 5%;
}
</style>
